<?php

namespace App\Listeners;

use App\Events\ProfitShare;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;

class ReplyOKToWeChat
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  ProfitShare  $event
     * @return void
     */
    public function handle(ProfitShare $event)
    {
        $arr = [
            'return_code' => 'SUCCESS',
            'return_msg' => 'OK'
        ];

        $xml = '<?xml version="1.0" encoding="utf-8"?>';
        $xml .= "<xml>";
        foreach ($arr as $key=>$val){
            $xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
        }
        $xml .="</xml>";

        Log::info('ReplyOKToWeChat Listener------begin');
        Log::info($xml);
        Log::info('ReplyOKToWeChat Listener------end');

        echo $xml;
    }

}
